package com.caocao.utils;

import com.caocao.domain.AccountConst;
import com.caocao.domain.RequestResult;

/**
 * 描述:前台界面返回数据使用的工具方法
 *
 * @Author:操文健
 * @Create Time:2017-09-10 6:08
 */
public class RequestResultUtil {

    public static RequestResult success(Object object, String userName){
        RequestResult requestResult = new RequestResult();
        requestResult.setCode(AccountConst.RESULT_CODE_SUSS);
        requestResult.setMsg("成功");
        requestResult.setUserName(userName);
        requestResult.setData(object);

        return requestResult;
    }

    public static RequestResult success(String userName){
        return success(null, userName);
    }

    public static RequestResult error(String errorMsg){
        RequestResult requestResult = new RequestResult();
        requestResult.setCode(AccountConst.RESULT_CODE_ERROR);
        requestResult.setMsg(errorMsg);
        requestResult.setData(null);

        return requestResult;
    }
}
